<?php

namespace App\Admin\Actions\User;

use Encore\Admin\Actions\BatchAction;
use Illuminate\Database\Eloquent\Collection;
use App\Models\Order\Order;

class WalletRecord extends BatchAction
{
    public $name = '批量发货';

    public function handle(Collection $collection)
    {
        foreach ($collection as $model) {
            if ($model->status == Order::STATUS_PAY_SUCCESS){
                $model->status = Order::STATUS_SEED_SCUESS;
                $model->save();
            }
        }

        return $this->response()->success('发货完成')->refresh();
    }

    public function dialog()
    {
        $this->confirm('确定批量发货？');
    }

}
